package com.dn.res.wideget;

import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.ScaleAnimation;
import android.widget.TextView;

/**
 * 描述：点击缩放的TextView*
 */
@SuppressLint("AppCompatCustomView")
public class ScaleTextView extends TextView {

    public ScaleTextView(Context context) {
        super(context);
    }

    public ScaleTextView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public ScaleTextView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {

        AnimationSet animationSet = new AnimationSet(true);

        ScaleAnimation scaleAnimation = new ScaleAnimation(0.8f,1
                ,0.8f,1, Animation.RELATIVE_TO_SELF
                ,0.5f, Animation.RELATIVE_TO_SELF,0.5f);

        scaleAnimation.setDuration(400);

        animationSet.addAnimation(scaleAnimation);

        ScaleTextView.this.startAnimation(animationSet);

        return super.onTouchEvent(event);
    }
}
